package com.wzq.solution;

import java.util.HashSet;
import java.util.Set;

public class Q217 {


        public static boolean containsDuplicate(int[] nums) {
            Set<Integer> s = new HashSet<Integer>();
            for(int i=0;i<nums.length;i++){
                if(s.contains(nums[i])){
                    return true;
                }
                s.add(nums[i]);
            }
            return false;
        }


    public static void main(String[] args) {
        int[] nums = new int[]{1,2,3,1};
        System.out.println(containsDuplicate(nums));

    }

  /*  public boolean containsDuplicate(int[] nums) {
        if(nums.length == 1){
            return false;
        }
        int bitmapLen = nums.length%32==0?nums.length/32:nums.length/32+1;
        int[] bitmap = new int[bitmapLen];
        for(int i=0;i<nums.length;i++){
            if((bitmap[i/32] ^ (1<<(i%32)) & (1<<(i%32))) ==1){
                return true;
            }
            bitmap[i/32] = bitmap[i/32]|(1<<(i%32));
        }
        return false;
    }*/


}
